home *** CD-ROM | disk | FTP | other *** search
/ AppleScript - The Beta Release / AppleScript - The Beta Release.iso / Example Scripts / Example Scripts (as text) / Finder Scripts / Close Subfolders < prev    next >
Encoding:
Text File  |  1992-12-02  |  503 b   |  26 lines  |  [TEXT/ToyS]

  1. -- This algorithm could be faster.  We should look at open
  2. -- windows and see if they need to be closed, not scan the
  3. -- entire disk closing everything.
  4. on closeAll(x)
  5.     close x
  6.     tell application "Finder"
  7.         repeat with sub in x
  8.             if class of sub = folder then
  9.                 my closeAll(sub)
  10.             end if
  11.         end repeat
  12.     end tell
  13. end closeAll
  14.  
  15. tell application "Finder"
  16.     copy selection to x
  17. end tell
  18.  
  19. if class of x = list then
  20.     repeat with entry in x
  21.         copy entry to y
  22.         closeAll(y)
  23.     end repeat
  24. else
  25.     closeAll(x)
  26. end if